import Vue from 'vue'

import VueRouter from 'vue-router'
/*
* 脚手架里面有一个特殊的标识符 @ 代表 src目录
* */

import Login from '@/views/login/index.vue'
import Dashboard from '@/views/dashboard/index.vue'
import UserList from '@/views/user/list.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Index',
        redirect: '/admin',
        meta: {
            title: '后台首页',
            needAuth: true,
        }
    },

    {
        path: '/login',
        name: 'Login',
        component: Login,
        meta: {
            title: '登录页面',
            needAuth: false,
        }
    },
    {
        path: '/admin',
        name: 'Dashboard',
        component: Dashboard,
        redirect: '/admin/user/list',

        meta: {
            title: '后台首页',
            needAuth: true,
        },
        children: [
            {
                path: 'user/list',
                name: 'user-list',
                component: UserList,
                meta: {
                    title: '用户列表',
                    needAuth: true,
                },
            }
        ]
    },

]

const router = new VueRouter({
    routes
})

export default router
